package com.tfjybj.itoo.exam.ext.mongo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tfjybj.itoo.exam.entity.OptionEntity;
import com.tfjybj.itoo.exam.entity.QuestionEntity;
import com.tfjybj.itoo.exam.model.QuestionMainModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.persistence.Column;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 问题实体类
 *
 * @author 商俊帅
 * @date 2022/01/06 14:41
 **/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
@Document("Question")
public class Question implements Serializable {

    @Id
    private String id;

    @Column(name = "question_content")
    private String questionContent;

    @Column(name = "question_content_html")
    private String questionContentHtml;

    @Column(name = "parent_id")
    private String parentId;

    @Column(name = "history_id")
    private String historyId;

    @Column(name = "question_type_id")
    private String questionTypeId;

    @Column(name = "question_classify_id")
    private String questionClassifyId;

    @Column(name = "version")
    private Integer version;

    @Column(name = "answer")
    private String answer;

    @Column(name = "is_out_of_order")
    private Integer isOutOfOrder;

    @Column(name = "is_alias")
    private Integer isAlias;

    @Column(name = "analysis")
    private String analysis;

    @Column(name = "source")
    private Integer source;

    @Column(name = "check_status")
    private Integer checkStatus;

    @Column(name = "check_result")
    private String checkResult;

    @Column(name = "degree_initial")
    private Integer degreeInitial;

    @Column(name = "degree_statistic")
    private Integer degreeStatistic;

    @Column(name = "option_count")
    private Integer optionCount;

    @Column(name = "is_effective")
    private Integer isEffective;

    @Column(name = "is_html")
    private Integer isHtml;

    @Column(name = "knowledge_point")
    private String knowledgePoint;

    @Column(name = "child_order")
    private Integer childOrder;

    @Column(name = "course_id")
    private String courseId;

    @Column(name = "answer_html")
    private String answerHtml;

    @Column(name = "analysis_html")
    private String analysisHtml;

    /**
     * 操作人
     */
    @Column(name = "operator")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String operator;
    /**
     * 删除标记
     */
    private int isDelete = 0;
    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark;
    /**
     * 创建日期
     */
    private Date createTime;
    /**
     * 更新日期
     */
    private Date updateTime;

    private List<Option> options;

    public QuestionMainModel toQuestionModel(QuestionMainModel questionMainModel){
        questionMainModel.setId(this.getId());
        questionMainModel.setQuestionId(this.getId());
        questionMainModel.setQuestionTypeId(this.getQuestionTypeId());
        questionMainModel.setAnswer(this.getAnswer());
        questionMainModel.setParentId(this.getParentId());
        questionMainModel.setQuestionContent(this.getQuestionContent());
        questionMainModel.setQuestionClassifyId(this.getQuestionClassifyId());
        questionMainModel.setDegreeInitial(this.getDegreeInitial());
        questionMainModel.setIsAlias(this.getIsAlias());
        questionMainModel.setQuestionContentHtml(this.getQuestionContentHtml());
        questionMainModel.setAnalysis(this.getAnalysis());
        questionMainModel.setCheckBox(false);
        return questionMainModel;
    }
}